<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习3</title>
</head>
<body>
<div id="app">
    <h1>演示条件判断</h1>
    输入的成绩1-100:
    <input
            type="text"
            v-model.number="grade"
            @input="checkInput"
            @keyup.enter="handleEnter"
            placeholder="请输入成绩"
            ref="input"
    />
    <p>当前成绩为{{grade}}</p>
    <p v-if="grade >= 90">优秀</p>
    <p v-else-if="grade >= 70">良好</p>
    <p v-else-if="grade >= 60">及格</p>
    <p v-else-if="grade >= 0">不及格</p>
</div>
<script src="vue.js"></script>
<script>
    let vm = new Vue({
        el: "#app",
        methods: {
            checkInput() {
                if (this.grade > 100) {
                    this.grade = 100;
                } else if (this.grade < 0) {
                    this.grade = 0;
                }
            },
            handleEnter() {
                this.$refs.input.blur();
            }
        }
    })
</script>
</body>
</html>